{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Minimum Size Subarray Sum\n",
    "\n",
    "[The Original Question](https://mp.weixin.qq.com/s/iwqoGA9e_smH_vs9NcM1MA)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Question\n",
    "\n",
    "Given an array of `n` positive integers and a positive integer `s`, find the minimal length of a contiguous subarray of which the `sum` ≥ `s`. If there isn't one, return `0` instead."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example\n",
    "\n",
    "```\n",
    "Input: s = 7, nums = [2,3,1,2,4,3]\n",
    "Output: 2\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Explanation\n",
    "\n",
    "the subarray `[4,3]` has the minimal length under the problem constraint."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[4, 3]\n"
     ]
    }
   ],
   "source": [
    "class Solution:\n",
    "    def minSubArrayLen(self, nums: list, s: int) -> list:\n",
    "        for i in range(1, len(nums) + 1):\n",
    "            for j in range(len(nums) + 1 - i):\n",
    "                if sum(nums[j:j + i]) >= s:\n",
    "                    return nums[j:j + i]\n",
    "                pass\n",
    "            pass\n",
    "        pass\n",
    "    \n",
    "    pass\n",
    "\n",
    "\n",
    "if __name__ == \"__main__\":\n",
    "    print(Solution().minSubArrayLen([2, 3, 1, 2, 4, 3], 7))\n",
    "    pass"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
